//
//  PaymentMainViewController.m
//  StraightTrain
//
//  Created by mk on 15/12/7.
//  Copyright © 2015年 mk. All rights reserved.
//

#import "PaymentMainViewController.h"

@interface PaymentMainViewController ()

@end

@implementation PaymentMainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    titleLabel.text = @"支付";
    
    SetBtnImages(btnBack, @"pay_back_white_icon.png", @"")

    [web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.strUrl]]];
}

-(void)backNav:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
    if([self.delegate respondsToSelector:@selector(hidderPayMentMainPaty)])
    {
        [self.delegate hidderPayMentMainPaty];
    }
}


-(void)webViewDidStartLoad:(UIWebView *)webView
{
    [indicat startAnimating];
    indicat.hidden = NO;
}

//完成
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [indicat stopAnimating];
    indicat.hidden = YES;
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
   // DLog(@"===%@",error);
    [indicat stopAnimating];
    indicat.hidden = YES;
}


-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    //    UIWebViewNavigationTypeLinkClicked，用户触击了一个链接。
    //    UIWebViewNavigationTypeFormSubmitted，用户提交了一个表单。
    //    UIWebViewNavigationTypeBackForward，用户触击前进或返回按钮。
    //    UIWebViewNavigationTypeReload，用户触击重新加载的按钮。
    //    UIWebViewNavigationTypeFormResubmitted，用户重复提交表单
    //    UIWebViewNavigationTypeOther，发生其它行为。
    
    //NSString *str = [self.webview stringByEvaluatingJavaScriptFromString:@"postStr('上海');"];
    if ([request isEqual:@""] && navigationType == UIWebViewNavigationTypeFormSubmitted)
    {
        //要传递的参数二
        NSString *str = [web stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"jsMethod();"]];
        NSLog(@"JS返回值：%@",str);
    }
    
    return YES;
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
